<template>
    <div class="bg">
      <van-nav-bar title="发布活动" fixed placeholder  right-text="按钮"  left-arrow @click-left="backHandler" >
        <template #right>
          <div class="edit_btn" @click="edit">
            <img src="@/assets/edit.png" alt="" class="img">
            <div>编辑</div>
          </div>
        </template>
      </van-nav-bar>
      <div class="activity_info info">
        <div class="title">活动信息</div>
        <div class="line"></div>
        <div class="input_item">
          <div class="label">*活动名称</div>
          <van-field
            v-model="activity.title"
            clearable
            label=""
            placeholder="请输入活动名称"
          >
          </van-field>
        </div>
        <div class="input_item">
          <div class="label">*活动时间</div>
          <van-field
            v-model="activity.begin_time"
            clearable
            label=""
            placeholder="请输入活动名称"
          >
          </van-field>
        </div>
        <div class="input_item">
          <div class="label">*报名费用</div>
          <van-field
            v-model="activity.fee"
            clearable
            label=""
            placeholder="请输入活动名称"
          >
          </van-field>
        </div>
        <div class="input_item">
          <div class="label">*活动路线</div>
          <van-field
            v-model="activity.title"
            clearable
            label=""
            placeholder="请输入活动名称"
          >
          </van-field>
        </div>
        <div class="input_item">
          <div class="label">*活动介绍</div>
          <van-field
            v-model="activity.intro"
            clearable
            label=""
            type="textarea"
            maxlength="500"
            placeholder="请输入留言"
            show-word-limit
          >
          </van-field>
        </div>
      </div>
      <div class="route_info info">
        <div class="title">线路图片</div>
        <div class="tips">上传图片大小不能超过4M，可添加1张图片，点击图片查看大图</div>
        <van-uploader :after-read="afterRead" :max-size="4 * 1024 * 1024" @oversize="onOversize">
          <img src="@/assets/group/uploader.png" alt="" class="uploader_img">
        </van-uploader>
      </div>
      <div class="bill_info info">
        <div class="title">海报图片</div>
        <div class="tips">上传图片大小不能超过4M，可添加1张图片，点击图片查看大图</div>
        <van-uploader :after-read="afterRead" :max-size="4 * 1024 * 1024" @oversize="onOversize" >
          <img src="@/assets/group/uploader.png" alt="" class="uploader_img">
        </van-uploader>
      </div>
      <div class="btns">
        <van-button class="btn">预览</van-button>
        <van-button class="btn">发布</van-button>
      </div>
    </div>
</template>

<script>
import { Toast } from 'vant'
export default {
  data () {
    return {
      activity: {
        title: '',
        begin_time: '',
        fee: '',
        intro: '',
        route_thumb: '',
        thumb: ''
      }
    }
  },
  mounted () {
  },
  methods: {
    backHandler () {
      this.$router.go(-1)
    },
    edit () {

    },
    onOversize (file) {
      console.log(file)
      Toast('上传图片大小不能超过4M')
    },
    afterRead (file) {
      // 此时可以自行将文件上传至服务器
      console.log(file)
    }
  }
}
</script>

<style lang="scss" scoped>
.bg{
  background: #F8F8F8;
  font-family:PingFang, PingFangSC-Semibold, PingFang SC;
  font-size: 20px;
  padding-bottom: 78px;
  .edit_btn {
    display: flex;
    font-size: 20px;
    font-weight: 600;
    color: #3F9C94;
    align-items: center;
    .img {
      width: 22px;
      height: 22px;
      margin-right: 3px;
    }
  }
  .info {
    background-color: #fff;
    padding: 16px 20px;
    margin-top: 10px;
    .title{
      font-size: 22px;
      font-weight: 600;
      color: #303030;
    }
    .line {
      width: 100%;
      height: 1px;
      margin-top: 13px;
      background-color: #E7E7E7;
    }
    .input_item {
      margin-top: 10px;
      .label {
        margin-bottom: 5px;
      }
    }
    .tips {
      font-size: 18px;
      font-weight: 400;
      color: #999999;
      margin-top: 8px;
      margin-bottom: 20px;
    }
    .uploader_img {
      width: 80px;
      height: 80px;
    }
  }
  .btns {
    position: fixed;
    box-sizing: border-box;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 68px;
    background: #FFFFFF;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 18px;
    .btn {
      width: calc((100vw - 46px) / 2);
      height: 54px;
      background: #0AD39F;
      box-shadow: 0px 2px 4px 0px rgba(10,211,159,0.3);
      border-radius: 27px;
      opacity: 0.1;
      font-size: 24px;
      font-family:PingFang, PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #FFFFFF;
    }
  }

  .van-field {
    background: #F8F8F8;
    border-radius: 8px;
  }
}

</style>
